﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;


namespace Final.App_Code
{
    public class Change_subjDataClass
    {

        public static Student GetStudentInfo(String admin) // not void
        {
            SqlConnection conn = null;
            Student s = new Student();
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SubjectManagementDBString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "Select * from Account where id = @id";
                comm.Parameters.AddWithValue("@id", admin);

                SqlDataReader dr = comm.ExecuteReader();

                while (dr.Read())
                {
                    s.Adminno = (string)dr["id"];
                    s.Name = (string)dr["Student_Name"];
                    s.Coursecode = (string)dr["Course_Code"];
                    s.Coursename = (string)dr["Course_Name"];

                    s.Module = (string)dr["Module"];

                    s.Contact = (int)dr["Contact"];
                    s.Email = (string)dr["Email"];
                    s.Role = (string)dr["Role"];
                }
                dr.Close();

            }
            catch (SqlException e)
            {
                throw e;

            }
            finally
            {
                conn.Close();


            } return s;

        }
    }

}